package com.zysdev.opengldouyin1demo.filter

import android.content.Context
import android.opengl.GLES20
import com.zysdev.opengldouyin1demo.R


//将摄像头数据传到FBO中，此滤镜返回的是fbo的纹理图层
class CameraFilter : BaseFBOFilter {

    private var mtx: FloatArray? = null
    private var vMatrix: Int? = null

    constructor(context: Context) : super(
        context, R.raw.camera_vert, R.raw.camera_frag
    ) {
        vMatrix = GLES20.glGetUniformLocation(program, "vMatrix")
    }

    override fun beforeDraw() {
        super.beforeDraw()
        GLES20.glUniformMatrix4fv(vMatrix!!, 1, false, mtx, 0)
    }

    fun setTransformMatrix(mtx: FloatArray) {
        this.mtx = mtx
    }
}